@extends('admin::layouts.master')
@section('title')
    {{$title}}
@endsection
<style>
    .layui-input-inline {
        padding-top: 10px;
    }
</style>
@section('tab')
    <div class="layui-fluid">
        <div class="layui-row">
            @if($detail)
                <div class="layui-form-item">
                    <label for="L_alias" class="layui-form-label">
                        <span class="x-red">*</span>门店名称</label>
                    <div class="layui-input-inline" style="width: 60%">{{$detail['name']}}</div>
                </div>

                <div class="layui-form-item">
                    <label for="L_alias" class="layui-form-label">
                        <span class="x-red">*</span>联系方式</label>
                    <div class="layui-input-inline" style="width: 60%">{{$detail['phone']}}</div>
                </div>

                <div class="layui-form-item">
                    <label for="L_alias" class="layui-form-label">
                        <span class="x-red">*</span>公司log</label>
                    <div class="layui-input-inline" style="width: 60%">
                        <img class="layui-upload-img" src="{{$detail['logo']['full_src']}}" height="100"
                             width="150">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label for="L_alias" class="layui-form-label">
                        <span class="x-red">*</span>地址</label>
                    <div class="layui-input-inline" style="width: 60%">{{$detail['province_name']['name']}}
                        - {{$detail['city_name']['name']}} - {{$detail['area_name']['name']}}</div>
                </div>
                <div class="layui-form-item">
                    <label for="L_alias" class="layui-form-label">
                        <span class="x-red">*</span>详细地址</label>
                    <div class="layui-input-inline" style="width: 60%">{{$detail['address']}}</div>
                </div>

                @if($detail['type'])
                    <div class="layui-form-item">
                        <label for="L_alias" class="layui-form-label">
                            <span class="x-red">*</span>检测站类型</label>
                        <div class="layui-input-inline" style="width: 60%"> {{$detail['type']['title']}} </div>
                    </div>
                @endif

                @if($detail['checkpoint_service_type'])
                    <div class="layui-form-item">
                        <label for="L_alias" class="layui-form-label">
                            <span class="x-red">*</span>服务类型</label>
                        <div class="layui-input-inline" style="width: 60%">
                            @foreach($detail['checkpoint_service_type'] as $name)
                                {{$name['title']}}  &nbsp &nbsp &nbsp
                            @endforeach
                        </div>
                    </div>
                @endif

                @if($detail['expenses'])
                    <div class="layui-form-item">
                        <label for="L_alias" class="layui-form-label">
                            <span class="x-red">*</span>年检费用</label>
                        <div class="layui-input-inline" style="width: 60%">{!! $detail['expenses'] !!}</div>
                    </div>
                @endif

            @else
                该用户未配置门店信息
            @endif

            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label"></label>
                <button class="layui-btn" status="1" lay-submit="">通过</button>
                <button class="layui-btn" status="3" lay-submit="">拒绝</button>
            </div>
        </div>
    </div>

@endsection

@section('tab_js')
    <script>
        layui.use(['form', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var layer = layui.layer;

            $(document).on('click', 'button', function () {
                var id = "{{$detail['id']}}";
                var status = $(this).attr('status');

                if (status == 3) {
                    layer.prompt({title: '请输入拒绝原因', formType: 2}, function (value, index) {
                        var data = {id: id, status: status, not_pass_reason: value};
                        layer.close(index);
                        examine(data);
                    });
                } else {
                    var data = {id: id, status: status};
                    examine(data);
                }
            });

            function examine(data) {
                $.ajax({
                    url: js_url('admin-shop-examine'),
                    type: 'post',
                    data: data,
                    dataType: "json",
                    success: function (result) {
                        if (result.state === 0) {
                            layer.msg(result.msg, {time: 600, icon: 6}, function () {
                                //关闭当前frame
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                        } else {
                            layer.msg(result.msg, {time: 600, icon: 5});
                        }
                    }
                });
            }
        });
    </script>
@endsection




